<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../../css/common.css" media="all">

	</head>

	<style type="text/css">
		.layui-table th {
			position: relative;
			min-height: 20px;
			height: 35px;
			line-height: 20px;
			font-size: 14px;
			padding: 0px 0px;
		}
		
		.layui-table td {
			position: relative;
			min-height: 20px;
			height: 100%;
			line-height: 14px;
			font-size: 14px;
			padding: 0px 0px;
		}
		
		/* .layui-input,
		.layui-textarea {
			display: block;
			width: 100%;
			padding: 0px 0px;
			border: 0px;
		} */
	</style>

	<body>
		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-form-item">
						<label class="layui-form-label">模板名称<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="name" required  lay-verify="required" placeholder="请输入模板名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">模板标题<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="title" required  lay-verify="required" placeholder="请输入模板标题" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">状态</label>
						<div class="layui-input-block">
							<select name="status">
							  <option value="0">禁用</option>
							  <option value="1">启用</option>
							</select> 
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">发起奖%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="launch_fee" required  lay-verify="required" placeholder="请输入发起奖%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">直推佣金%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="direct_fee" required  lay-verify="required" placeholder="请输入直推佣金%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">间推佣金%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="indirect_fee" required  lay-verify="required" placeholder="请输入间推佣金%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">团长佣金%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="leader_fee" required  lay-verify="required" placeholder="请输入团长佣金%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">管理奖%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="team_fee" required  lay-verify="required" placeholder="请输入管理奖%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">合伙人佣金%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="copartner_fee" required  lay-verify="required" placeholder="请输入合伙人佣金%" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">服务站佣金%<span style="color: red;">*</span></label>
						<div class="layui-input-block">
							<input type="number" onkeyup="checkIsPreset(this)" name="station_fee" required  lay-verify="required" placeholder="请输入服务站佣金%" autocomplete="off" class="layui-input">
						</div>
					</div>
				<!-- 	<div class="layui-form-item">
						<label class="layui-form-label">备注1</label>
						<div class="layui-input-block">
							<input type="text" name="a_fee" placeholder="请输入备注1" autocomplete="off" class="layui-input">
						</div>
					</div> -->
					<!-- <div class="layui-form-item">
						<label class="layui-form-label">备注2</label>
						<div class="layui-input-block">
							<input type="text" name="b_fee" placeholder="请输入备注2" autocomplete="off" class="layui-input">
						</div>
					</div> -->
					<!-- <div class="layui-form-item">
						<label class="layui-form-label">备注3</label>
						<div class="layui-input-block">
							<input type="text" name="c_fee" placeholder="请输入备注3" autocomplete="off" class="layui-input">
						</div>
					</div> -->
					<div class="layui-form-item">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" name="remark" placeholder="请输入备注" autocomplete="off" class="layui-input">
						</div>
					</div>
					
					
					
					
					
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>

				</form>
			</div>
		</div>
		<script src="../../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../../js/jquery.min.js"></script>
		<script src="../../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../../js/common.js"></script>
		<script>
			var _data = {} 
			layui.config({
				base: '../../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form'], function() {
				var $ = layui.$,
					admin = layui.admin,
					form = layui.form;
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					console.log(data, 'data')
					let parms = {
						shopid: '0', // 商品id
						bid: '5', // 5:拼团
						...data
					}
					parms.shopid = parseInt(parms.shopid)
					parms.station_fee = parseInt(parms.station_fee)
					parms.copartner_fee = parseInt(parms.copartner_fee)
					parms.direct_fee = parseInt(parms.direct_fee)
					parms.indirect_fee = parseInt(parms.indirect_fee)
					parms.launch_fee = parseInt(parms.launch_fee)
					parms.leader_fee = parseInt(parms.leader_fee)
					parms.team_fee = parseInt(parms.team_fee)
					parms.status = parseInt(parms.status)
					layer.confirm('确定要提交数据？', function() {
						loading();
						submitdata(server.shop_feetemp_save,parms)
					}, function() {
						layer.msg('取消操作');
					});
					return false
				});

				function submitdata(_url, data) {
					console.log('tijiao', _url)
					$.post(_url,data,function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.closeAll('loading')
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					})
				}
			});
		</script>
		<script language="JavaScript" type="text/javascript">
		function checkIsPreset(obj){
		  obj.value = obj.value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符
		  obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是.
		  obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
		  obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
		  //判断百分比不能超过100%
		  if(obj.value>=100){
		      // alert("分红比例不能大于等于100");
			  alert('比例不能大于等于100,请重新输入')
		      obj.value ="";
		      return;
		  };
		  //如果有小数点，判断 只能保留两位
		  if(obj.value.indexOf(".")>-1){
		      if(obj.value.split(".")[1].length>2){
		          alert("小数点后只能保留两位");
		          obj.value ="";
		          return;
		      }
		  }
		}
		
		</script>
	</body>

</html>